import http from '@/utils/request'

const API_PREFIX = '/web/reports'

const options = {
  ignoreCancelToken: false
}

export const fetchReportList = params => http.post(`${API_PREFIX}/sys/report/new-card-list`, params, {}, options)

export const fetchOldReportList = params => http.post(`${API_PREFIX}/sys/report/card-list`, params)

export const fetchReportGrid = params => http.get(`${API_PREFIX}/sys/report/grid-list`, {
  params
}, options)

export const fetchReport = id => http.get(`${API_PREFIX}/sys/report/${id}/info`)

export const deleteReport = params => http.delete(`${API_PREFIX}/sys/report/${params.id}/delete`, { params })

export const updateReport = params => http.put(`${API_PREFIX}/sys/report/${params.id}/update`, params)

export const cloneReport = params => http.post(`${API_PREFIX}/sys/report/clone/${params.reportId}`, params)

export const cloneByTenantReport = params => http.post(`${API_PREFIX}/sys/report/cloneByTenantCode`, params)

export const fetchCommunityReport = id => http.get(`${API_PREFIX}/sys/share/resource/${id}`)

export const updateCommunityReport = params => http.put(`${API_PREFIX}/sys/share/${params.originalId}/update`, params)

export const createQuery = params => http.post(`${API_PREFIX}/sys/query/save`, params)

export const updateQuery = params => http.put(`${API_PREFIX}/sys/query/${params.id}/update`, params)